<template>
  <div class="">
    <el-row>
      <el-col :span="24">
        <div class="grid-content bg-purple-dark">
          <el-breadcrumb separator-class="el-icon-arrow-right" style="font-size: 15px">
            <el-breadcrumb-item :to="{ path: '/CompanyIndexView' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item v-for="(item,index) in breadList" :key="index" :to="{path:item.path}">{{item.name}}</el-breadcrumb-item>
          </el-breadcrumb>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>

export default {
  name: 'Breadcrumb',
  components: {},
  data() {
    return {
      breadList:[]
    };
  },
  watch:{
    $route(){
      this.getBreadcrumb();
    }
  },
  created() {
    this.getBreadcrumb();
  },
  methods: {
    isHome(route){
      return route.name ==="CompanyIndexView";
    },
    getBreadcrumb(){
      let matched = this.$route.matched;
      if(!this.isHome(matched[0])){
        matched = [{path:'/CompanyIndexView',meta:{title:'首页'}}].concat(matched);
      }
      this.breadList = matched;
    }
  },

}
</script>